package work01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test01 {
    public static void main(String[] args) {
        FileOutputStream file = null;
        FileInputStream in = null;
        try{
            file = new FileOutputStream("D:\\yourLove\\123.txt");
            String str = "Hello World";
            byte []b = str.getBytes();
            try{
                file.write(b);
            }catch (IOException e){
                e.printStackTrace();
            }
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }
        try {
            in = new FileInputStream("D:\\yourLove\\123.txt");
            byte []b = new byte[1024];
            try{
                int k = in.read(b);
                System.out.println(new String(b,0,k));
            }catch (IOException e){
                e.printStackTrace();
            }
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }finally {
            try {
                file.close();
                in.close();
            }catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
